﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace DatNuocViet.Areas.Admin.Controllers
{
    public class CustomAuthentication : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies["IsLoggin"];
            if (cookie != null)
                return true;
            else
                return false;
        }
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            filterContext.Result = new RedirectToRouteResult(
                new RouteValueDictionary
                {
                    {"area","Admin"},
                    { "controller", "AdminHome" },
                    { "action", "Login" },
                });
        }
    }
}